﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Media;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace BeerScanatronUI
{
    public static class PlaySound
    {
        public enum Sounds
        {
            UnknownCode,
            BeverageLimitReached,
            TransactionCompleted,
            DrinkerCannotBeServed
        }

        public static void Play(Sounds sound)
        {
            string wavFileName;
            
            switch (sound)
            {
                case Sounds.UnknownCode:
                    wavFileName = Consts.Sounds.CarAlarm;
                    break;
                case Sounds.BeverageLimitReached:
                case Sounds.DrinkerCannotBeServed:
                    wavFileName = Consts.Sounds.Klaxon;
                    break;
                case Sounds.TransactionCompleted:
                    wavFileName = Consts.Sounds.CashRegister;
                    break;
                default:
                    // Unmapped sound.
                    return;
            }

            Assembly assem = Assembly.GetExecutingAssembly();
            Stream stream = assem.GetManifestResourceStream(wavFileName);
            SoundPlayer player = new SoundPlayer(stream);
            player.Play();
        }
    }
}
